<?php
include 'checkLogin.php';

@$name = $_REQUEST['name'];

include 'db/li.php';

@$orderNames = dbSelectAll('select name from `order`');

foreach ($orderNames as $orderName){
	if($orderName['name'] == $name){
		$mes = '已有此订单，请重新创建';
		include 'addOrder.php';
		die;
	}
}
@$flog = dbInsert("insert into `order`(name,pay,startDate) values(:name,'否',now())",
					array('name'=>$name));
if(!$flog){
	$mes = '创建新订单失败';
	include 'addOrder.php';
	die;
}
@$id = dbSelect('select id from `order` where name=:name',array('name'=>$name));
header('Refresh:0;url=index.php?noPayOrderId='.$id['id']);